<dependency> <groupId>org.switchyard.components</groupId> <artifactId>switchyard-component-camel-jpa</artifactId> <version>SWITCHYARD-VERSION</version> </dependency>
The jpa binding in SwitchYard provides support for consuming and storing JPA entities. It supports both sides - service binding for entity consumption and reference for entity storing.
The JPA binding is built on top of camel-jpa and supports most of options for this endpoint. Please reffer camel documentation for detailed description of them.
This binding have it's own namespace. To use it you must declare namespace with uri urn:switchyard-component-camel-jpa:config:1.0. Your Maven project should also have following dependency:
<dependency> <groupId>org.switchyard.components</groupId> <artifactId>switchyard-component-camel-jpa</artifactId> <version>SWITCHYARD-VERSION</version> </dependency>
Following options can be apiled to <binding.jpa> definition:
entityClassName
persistenceUnit
transactionManager
Supported options are:
consumeDelete
consumeLockEntity
maximumResults
consumer.query
consumer.namedQuery
consumer.nativeQuery
consumer.resultClass
consumer.transacted
The consumeLockEntity option causes problems with transaction management.
Here's an example of what a mail service binding looks like:
<sca:composite name="camel-binding" targetNamespace="urn:switchyard-quickstart:camel-binding:0.1.0"> <sca:service name="GreetingService" promote="GreetingService"> <camel:binding.jpa> <camel:entityClassName>org.switchyard.quickstarts.camel.jpa.binding.domain.Greet</camel:entityClassName> <camel:persistenceUnit>JpaEvents</camel:persistenceUnit> <camel:transactionManager>#jtaTransactionManager</camel:transactionManager> <camel:consume> <camel:consumeLockEntity>false</camel:consumeLockEntity> <camel:consumer.transacted>true</camel:consumer.transacted> </camel:consume> </camel:binding.jpa> </sca:service> </sca:composite>
Binding a reference with jpa can be used to store entity. The following configuration options are available for binding.jpa when binding references:
flushOnSend
usePersist
<sca:composite name="camel-binding" targetNamespace="urn:switchyard-quickstart:camel-binding:0.1.0"> <sca:reference name="GreetingService" promote="camel-binding/GreetingService" multiplicity="1..1"> <camel:binding.jpa> <camel:entityClassName>org.switchyard.quickstarts.camel.jpa.binding.domain.Greet</camel:entityClassName> <camel:persistenceUnit>JpaEvents</camel:persistenceUnit> <camel:produce> <camel:flushOnSend>false</camel:flushOnSend> </camel:produce> </camel:binding.jpa> </sca:reference> </sca:composite>